package com.ck.daoImpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ck.dao.PanduanDAO;
import com.ck.domain.Panduan;

public class PanduanDAOImpl extends SqlMapClientDaoSupport implements
		PanduanDAO {

	public List<Panduan> getAllPanduan() {
		return (List<Panduan>)getSqlMapClientTemplate().queryForList("getAllPanduan");
	}
	
	public Panduan getPanduanById(Integer id) {
		return (Panduan) getSqlMapClientTemplate().queryForObject("getPanduanById",id);
	}

	public List<Panduan> getPanduanForExercise(Panduan panduan) {
		return (List<Panduan>) getSqlMapClientTemplate().queryForList("getPanduanForExercise",panduan);
	}

	public List<Panduan> getPanduanForPaper(Integer difficulty, Integer score,
			Integer chapter) {
		Panduan panduan = new Panduan();
		panduan.setDifficulty(difficulty);
		panduan.setScore(score);
		panduan.setChapter(chapter);
		
		return (List<Panduan>) getSqlMapClientTemplate().queryForList("getPanduanForPaper",panduan);
	}

	public List<Panduan> getPanduanByChapter(Integer chapter) {
		return (List<Panduan>) getSqlMapClientTemplate().queryForList("getPanduanByChapter",chapter);
	}

	public void addNewPanduan(Panduan panduan) {
		getSqlMapClientTemplate().insert("addNewPanduan", panduan);
	}

	public void updatePanduanInfo(Panduan panduan) {
		getSqlMapClientTemplate().update("updatePanduanInfo", panduan);
	}

	public void removePanduanImage(Panduan panduan) {
		getSqlMapClientTemplate().update("removePanduanImage", panduan);
	}

}
